Golang encoding/base32.Encoding.EncodedLen function example
package encoding/base32
EncodedLen returns the length in bytes of the base32 encoding of an input buffer of length n(1st parameter).
Golang encoding/base32.Encoding.EncodedLen function usage example
// Base32ExtEncode encodes binary data to base32 extended (RFC 4648) encoded text.
func Base32ExtEncode(data []byte) (text []byte) {
n := base32.HexEncoding.EncodedLen(len(data)) // <--- EncodedLen
buf := bytes.NewBuffer(make([]byte, 0, n))
encoder := base32.NewEncoder(base32.HexEncoding, buf)
encoder.Write(data)
encoder.Close()
if buf.Len() != n {
panic("internal error")
}
return buf.Bytes()
}
Reference :
Advertisement
Something interesting
Tutorials
+17.6k Golang : delete and modify XML file content
+16.6k Golang : Generate QR codes for Google Authenticator App and fix "Cannot interpret QR code" error
+7.4k Golang : How to detect if a sentence ends with a punctuation?
+5.3k Python : Convert(cast) string to bytes example
+6k Linux/MacOSX : Search for files by filename and extension with find command
+20.2k Golang : Compare floating-point numbers
+6.5k Golang : Spell checking with ispell example
+5.6k Fix fatal error: evacuation not done in time problem
+5.8k Golang : Find change in a combination of coins example
+22.7k Golang : Strings to lowercase and uppercase example
+5k Python : Convert(cast) bytes to string example
+18.4k Golang : How to remove certain lines from a file